package com.miao.generator.service.impl;

import com.miao.entity.TableListEntity;
import com.miao.generator.dao.GeneratorMapper;
import com.miao.generator.service.GeneratorService;
import com.miao.util.Result;
import com.miao.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GeneratorServiceImpl implements GeneratorService {
    @Autowired
    private GeneratorMapper dao;


    @Override
    public Result<Object> Page(Map<String, Object> params) {
        int pageSize = Integer.parseInt(params.get("pageSize").toString());
        int currentPage = Integer.parseInt(params.get("currentPage").toString());
        List<TableListEntity> tableListEntities = dao.GetTableList((currentPage - 1) * pageSize, pageSize);
        return new Result<>().success(new PageData<>(tableListEntities, tableListEntities.size()));
    }
}
